package com.alageek.study.component;

import com.alageek.study.entity.Employee;
import com.alageek.study.entity.ResultEntity;
import com.alageek.study.service.EmployeeRemoteService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class MyFallBackFactory implements FallbackFactory<EmployeeRemoteService> {
    @Override
    public EmployeeRemoteService create(Throwable throwable) {
        return new EmployeeRemoteService() {
            @Override
            public Employee getEmployeeRemote() {
                return new Employee(555, "tom555-0000", 555.55);
            }

            @Override
            public ResultEntity<Employee> getEmpRemote(String signal) {
                return ResultEntity.failed("circuit break workded, with signal = " + signal);
            }
        };
    }
}
